package com.yx.coredata.common;

import java.util.LinkedList;


public class Stack<T> {
    private LinkedList<T> stack = new LinkedList<T>();
    //入栈
    public T push(T value){
        stack.addFirst(value);
        return value ;
    }
    //出栈
    public T pop(){
        return stack.pop();
    }
    //取栈顶元素
    public T top(){
        if(stack.isEmpty())
            return null ;
        return stack.getFirst();
    }
    //是否栈空
    public boolean isEmpty(){
        return stack.isEmpty();
    }

    //栈的长度
    public Integer size(){ return stack.size(); }
}
